<?php
namespace lib\src;

class iException extends \Exception{
	/* 信息 */
	protected $message;
	/* 异常码 */
	protected $code;
	/* 异常文件 */
	protected $file;
	/* 行号*/
	protected $line;
	/* 追踪信息 */
	protected $trace;
	/* 上一个异常 */
	protected $previous;
	
	/**
     * 注册异常处理
     * @access public
     * @return void
     */
    public static function register()
    {
        error_reporting(E_ALL);
        set_error_handler([__CLASS__, 'appError']);
        set_exception_handler([__CLASS__, 'appException']);
        register_shutdown_function([__CLASS__, 'appShutdown']);
    }
	
	/**
	 * 自定义异常类 
	 */	
	public static function getError(){
		//message
		$message = $this->getMessage();
		//code
		$code = $this->getCode();
		//file
		$file = $this->getFile();
		//line
		$line = $this->getLine();
		//trace
		$trace = $this->getTraceAsString();
		//previous
		$previous = $this->getPrevious();
		//返回
		return $message;
	}
}
?>